package com.example.demo.main.regex;


import java.util.regex.Matcher;
import java.util.regex.Pattern;


/**
 * @author xieluoyin
 */
public class T {
    public static void main(String[] args) {
        System.out.println(parseFirstNum("y-9uj91419f956fd9"));
    }


    public static Integer parseFirstNum(String source) {
        String regex = "-?[1-9]\\d*";
        System.out.println(regex);
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(source);
        String result=null;
        if (matcher.find())
        {
            result= matcher.group();
        }
        if (result!=null){
            return Integer.parseInt(result);
        }
        return null;

    }

}
